<%-- 
    Document   : roompanel
    Created on : Apr 15, 2011, 1:39:20 AM
    Author     : Setia_Negara
--%>

<%@page import="logic.Main"%>
<%@page import="classes.*"%>
<%@page import="java.util.ArrayList"%>
<%@page import="database.database"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<div class="onecategory" id="home">
    Home
</div>
<%
    ArrayList<Room> listPelarian = Main.getRoomInCategory(0);
    if (!listPelarian.isEmpty()) {
        for (int x = 0; x < listPelarian.size(); x++) {
            out.println("<div class=\"oneroom\" onclick=\"joinClick(\'"+listPelarian.get(x).name+"\');\">");
            out.println("<font color='green'>");
            out.println("#"+listPelarian.get(x).name);
            out.println("</font>");
            out.println("</div>");
        }
    }
%>
<br />
<%
            database db = new database();
            ArrayList<Category> categs = db.getCategory(0);
            System.out.println("query here\n");
            ArrayList<Category> subcategs;

            if (categs != null) {

                for (int i = 0; i < categs.size(); ++i) {
                    out.println("<div class=\"onecategory\" id=\"" + categs.get(i).id + "\" onclick=\"toggle('sublist" + i + "')\">");
                    out.println(categs.get(i).name);

                    out.println("</div>");
                    System.out.println("alamak\n");
                    subcategs = db.getCategory(categs.get(i).id);
                    System.out.println("alamakjang\n");
                    out.println("<div class=\"sublist\" id=\"sublist" + i + "\">");
                    if (subcategs != null) {
                        for (int j = 0; j < subcategs.size(); ++j) {
                            //out.println("<img class=\"tree\" src=\"images/tree-nodes.png\" height=\"15px\" />");
                            out.println("<div class=\"onesub\" id=\"" + subcategs.get(j).id + "\" onclick=\"toggle('roomlist" + i + j + "')\">");
                            out.println(subcategs.get(j).name);
                            out.println("</div>");

                            out.println("<div class=\"roomlist\" id=\"roomlist" + i + j + "\">");
                            // tampilkan room disini
                            ArrayList<Room> list = Main.getRoomInCategory(subcategs.get(j).id);
                            if (!list.isEmpty()) {
                                for (int x = 0; x < list.size(); x++) {
                                    out.println("<div class=\"oneroom\" onclick=\"joinClick(\'"+list.get(x).name+"\');\">");
                                    out.println("<font color='green'>");
                                    out.println("#"+list.get(x).name);
                                    out.println("</font>");
                                    out.println("</div>");
                                }
                            }
                            out.println("</div>");
                        }
                    }
                    // tampilkan room disini
                    ArrayList<Room> list = Main.getRoomInCategory(categs.get(i).id);
                    if (!list.isEmpty()) {
                        for (int x = 0; x < list.size(); x++) {
                            out.println("<div class=\"onesub\"  onclick=\"joinClick(\'"+list.get(x).name+"\');\">");
                            out.println("<font color='green'>");
                            out.println("#"+list.get(x).name);
                            out.println("</font>");
                            out.println("</div>");
                        }
                    }
                    out.println("</div>");

                }

            } else {
                System.out.println("bye");
            }
%>
